/*
 * @Description: 个人资料   PersonalData
 * @version: 
 * @Company: 
 * @Author: ZhengZhuang
 * @Date: 2019-08-31 11:55:27
 * @LastEditors: zhengzhuang
 * @LastEditTime: 2020-08-29 15:33:41
 */
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:C20Driver/routers/navigator_util.dart';
import 'package:provider/provider.dart';
import 'package:C20Driver/provider/driver_information.dart';
import 'package:C20Driver/widget/arrow_list.dart';

class PersonalData extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    DriverInformation provider =
        Provider.of<DriverInformation>(context, listen: false);
    return Scaffold(
      appBar: AppBar(
        elevation: 0,
        iconTheme: IconThemeData(
          color: Colors.white, //修改颜色
        ),
        title: Text(
          '个人资料',
          style: TextStyle(
              color: Color(0xffffffff),
              fontSize: ScreenUtil().setWidth(34),
              fontWeight: FontWeight.w500),
        ),
        flexibleSpace: Container(
          decoration: BoxDecoration(
            gradient: LinearGradient(
              colors: [
                Color(0xff697794),
                Color(0xff374258),
              ],
              begin: Alignment.centerLeft,
              end: Alignment.centerRight,
            ),
          ),
        ),
      ),
      body: Container(
          width: double.infinity,
          height: double.infinity,
          color: Color(0xffEFF3F9),
          child: Stack(
            alignment: AlignmentDirectional.topCenter,
            children: [
              Container(
                padding: EdgeInsets.fromLTRB(
                    ScreenUtil().setWidth(20),
                    ScreenUtil().setWidth(42),
                    ScreenUtil().setWidth(32),
                    ScreenUtil().setWidth(30)),
                alignment: Alignment.topCenter,
                width: double.infinity,
                height: ScreenUtil().setWidth(300),
                decoration: BoxDecoration(
                  gradient: LinearGradient(
                    colors: [
                      Color(0xff697794),
                      Color(0xff374258),
                    ],
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                  ),
                ),
                child: Column(
                  children: [
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceBetween,
                      children: [
                        Row(
                          children: [
                            Consumer<DriverInformation>(
                                builder: (context, state, chile) {
                              return Image.network(
                                state.driverInfo.headimgurl,
                                width: ScreenUtil().setWidth(120),
                                height: ScreenUtil().setWidth(120),
                              );
                            }),
                            SizedBox(
                              width: ScreenUtil().setWidth(20),
                            ),
                            Column(
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: [
                                Text(
                                  '${provider.driverInfo.driverName}',
                                  style: TextStyle(
                                      color: Color(0xffffffff),
                                      fontSize: ScreenUtil().setWidth(32),
                                      fontWeight: FontWeight.w500),
                                ),
                                SizedBox(
                                  height: ScreenUtil().setWidth(10),
                                ),
                                Text(
                                  '${provider.driverInfo.driverPhone}',
                                  style: TextStyle(
                                      color: Color(0xffffffff),
                                      fontSize: ScreenUtil().setWidth(28),
                                      fontWeight: FontWeight.w400),
                                ),
                              ],
                            ),
                          ],
                        ),
                        InkWell(
                          onTap: () {
                            NavigatorUtil.jump(context, '/personalDetailData');
                          },
                          child: Container(
                            alignment: Alignment.center,
                            width: ScreenUtil().setWidth(220),
                            height: ScreenUtil().setWidth(62),
                            decoration: BoxDecoration(
                              color: Colors.transparent,
                              border: Border.all(
                                width: ScreenUtil().setWidth(1),
                                color: Color(0xffffffff),
                              ),
                              borderRadius: BorderRadius.all(
                                Radius.circular(
                                  ScreenUtil().setWidth(31),
                                ),
                              ),
                            ),
                            child: Text(
                              '编辑个人信息',
                              style: TextStyle(
                                  color: Color(0xffffffff),
                                  fontSize: ScreenUtil().setWidth(26),
                                  fontWeight: FontWeight.w400),
                            ),
                          ),
                        )
                      ],
                    ),
                    SizedBox(
                      height: ScreenUtil().setWidth(90),
                    ),
                  ],
                ),
              ),
              Positioned(
                top: ScreenUtil().setWidth(200),
                child: Column(
                  children: [
                    Container(
                      width: ScreenUtil().setWidth(686),
                      decoration: BoxDecoration(
                        color: Color(0xffffffff),
                        borderRadius: BorderRadius.all(
                          Radius.circular(
                            ScreenUtil().setWidth(32),
                          ),
                        ),
                      ),
                      child: Column(
                        children: [
                          Padding(
                            padding: EdgeInsets.fromLTRB(
                              ScreenUtil().setWidth(32),
                              ScreenUtil().setWidth(36),
                              ScreenUtil().setWidth(32),
                              ScreenUtil().setWidth(30),
                            ),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  '服务城市',
                                  style: TextStyle(
                                    color: Color(0xff333333),
                                    fontSize: ScreenUtil().setWidth(30),
                                  ),
                                ),
                                Text(
                                  '${provider.driverInfo.carAddress}',
                                  style: TextStyle(
                                    color: Color(0xff333333),
                                    fontSize: ScreenUtil().setWidth(30),
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Padding(
                            padding: EdgeInsets.fromLTRB(
                              ScreenUtil().setWidth(32),
                              ScreenUtil().setWidth(30),
                              ScreenUtil().setWidth(20),
                              ScreenUtil().setWidth(36),
                            ),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  '证件信息',
                                  style: TextStyle(
                                    color: Color(0xff333333),
                                    fontSize: ScreenUtil().setWidth(30),
                                  ),
                                ),
                                InkWell(
                                  onTap: () {
                                    NavigatorUtil.jump(
                                        context, '/certificatesInfo');
                                  },
                                  child: Row(
                                    children: [
                                      Text(
                                        '查看详情',
                                        style: TextStyle(
                                          color: Color(0xffB5B5B5),
                                          fontSize: ScreenUtil().setWidth(30),
                                        ),
                                      ),
                                      SizedBox(
                                        width: ScreenUtil().setWidth(8),
                                      ),
                                      Icon(
                                        Icons.chevron_right,
                                        color: Color(0xffB5B5B5),
                                        size: ScreenUtil().setWidth(28),
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ),
                          )
                        ],
                      ),
                    ),
                    SizedBox(
                      height: ScreenUtil().setWidth(32),
                    ),
                    Container(
                      padding: EdgeInsets.all(
                        ScreenUtil().setWidth(32),
                      ),
                      width: ScreenUtil().setWidth(686),
                      decoration: BoxDecoration(
                        color: Color(0xffffffff),
                        borderRadius: BorderRadius.all(
                          Radius.circular(
                            ScreenUtil().setWidth(32),
                          ),
                        ),
                      ),
                      child: Column(
                        children: [
                          Row(
                            children: [
                              Text(
                                '车辆信息',
                                style: TextStyle(
                                  color: Color(0xff333333),
                                  fontSize: ScreenUtil().setWidth(30),
                                ),
                              ),
                              SizedBox(
                                width: ScreenUtil().setWidth(10),
                              ),
                            ],
                          ),
                          SizedBox(
                            height: ScreenUtil().setWidth(40),
                          ),
                          Image.asset(
                            'assets/icon/carimg.png',
                            width: ScreenUtil().setWidth(105),
                            height: ScreenUtil().setWidth(105),
                          ),
                          SizedBox(
                            height: ScreenUtil().setWidth(20),
                          ),
                          Text(
                            '${provider.driverInfo.vehicleNumberPlate}',
                            style: TextStyle(
                                color: Color(0xff333333),
                                fontSize: ScreenUtil().setWidth(30),
                                fontWeight: FontWeight.w500),
                          ),
                          SizedBox(
                            height: ScreenUtil().setWidth(10),
                          ),
                          Text(
                            '${provider.driverInfo.brandModels}',
                            style: TextStyle(
                                color: Color(0xff999999),
                                fontSize: ScreenUtil().setWidth(28),
                                fontWeight: FontWeight.w400),
                          ),
                        ],
                      ),
                    ),
                    SizedBox(
                      height: ScreenUtil().setWidth(32),
                    ),
                    Container(
                      width: ScreenUtil().setWidth(686),
                      decoration: BoxDecoration(
                        color: Color(0xffffffff),
                        borderRadius: BorderRadius.all(
                          Radius.circular(
                            ScreenUtil().setWidth(32),
                          ),
                        ),
                      ),
                      child: Column(
                        children: [
                          Padding(
                            padding: EdgeInsets.fromLTRB(
                              ScreenUtil().setWidth(32),
                              ScreenUtil().setWidth(36),
                              ScreenUtil().setWidth(20),
                              ScreenUtil().setWidth(30),
                            ),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                Text(
                                  '网约车驾驶证/运输证',
                                  style: TextStyle(
                                    color: Color(0xff333333),
                                    fontSize: ScreenUtil().setWidth(30),
                                  ),
                                ),
                                InkWell(
                                  onTap: () {
                                    NavigatorUtil.jump(
                                        context, '/professionalQualification');
                                  },
                                  child: Row(
                                    children: [
                                      Text(
                                        '查看详情',
                                        style: TextStyle(
                                          color: Color(0xffB5B5B5),
                                          fontSize: ScreenUtil().setWidth(30),
                                        ),
                                      ),
                                      SizedBox(
                                        width: ScreenUtil().setWidth(8),
                                      ),
                                      Icon(
                                        Icons.chevron_right,
                                        color: Color(0xffB5B5B5),
                                        size: ScreenUtil().setWidth(28),
                                      )
                                    ],
                                  ),
                                )
                              ],
                            ),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
              ),
            ],
          )
          //   Column(
          //     children: <Widget>[
          //       _headPortrait(context),
          //       Divider(height: 0, color: Colors.grey),
          //       InkWell(
          //         child: ArrowList(
          //             titleBox: '姓名',
          //             contextDex: provider.driverInfo.driverName,
          //             rightIconState: true),
          //         onTap: () => NavigatorUtil.jump(context, '/modifyNickname'),
          //       ),
          //       Divider(height: 0, color: Colors.grey),
          //       ArrowList(
          //           titleBox: '手机号', contextDex: provider.driverInfo.driverPhone),
          //       Divider(height: 0, color: Colors.grey),
          //       ArrowList(titleBox: '身份证号', contextDex: provider.driverInfo.idNo),
          //       SizedBox(height: ScreenUtil().setWidth(30.0)),
          //       // ArrowList(titleBox: '城市', contextDex: '青岛市'),
          //       Divider(height: 0, color: Colors.grey),
          //       InkWell(
          //         child: ArrowList(
          //             titleBox: '驾驶证与身份证信息', contextDex: '', rightIconState: true),
          //         onTap: () => NavigatorUtil.jump(context, '/uploadIdCard'),
          //       ),
          //       Divider(height: 0, color: Colors.grey),
          //       InkWell(
          //         child: ArrowList(
          //             titleBox: '行驶证与车辆信息', contextDex: '', rightIconState: true),
          //         onTap: () =>
          //             NavigatorUtil.jump(context, '/drivingLicenseVehicle'),
          //       ),
          //       Divider(height: 0, color: Colors.grey),
          //       InkWell(
          //         child: ArrowList(
          //             titleBox: '网约车驾驶证与车辆运营证',
          //             contextDex: '',
          //             rightIconState: true),
          //         onTap: () =>
          //             NavigatorUtil.jump(context, '/professionalQualification'),
          //       ),
          //     ],
          //   ),
          // ),
          ),
    );
  }

  /// 头像上传
  Widget _headPortrait(context) {
    DriverInformation provider = Provider.of<DriverInformation>(context);
    return InkWell(
      child: Container(
        color: Colors.white,
        padding: EdgeInsets.only(
          top: ScreenUtil().setWidth(23.0),
          bottom: ScreenUtil().setWidth(23.0),
          left: ScreenUtil().setWidth(23.0),
          right: ScreenUtil().setWidth(23.0),
        ),
        child: Row(
          children: <Widget>[
            Expanded(
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  Text(
                    '头像',
                    style: TextStyle(
                      fontSize: ScreenUtil().setSp(32.0),
                      color: Colors.black87,
                    ),
                  ),
                  ClipOval(
                    child: Image.network(provider.driverInfo.headimgurl,
                        width: ScreenUtil().setWidth(100.0),
                        height: ScreenUtil().setWidth(100.0),
                        fit: BoxFit.fill),
                  ),
                ],
              ),
            ),
            Icon(Icons.keyboard_arrow_right, color: Colors.black38)
          ],
        ),
      ),
      onTap: () => provider.setHeadimgurl(),
    );
  }
}
